﻿@model LayuiMvcUtil.Result.DataResult<LayuiMvc.DataModel.Community.PostDetailModel>
<div class="layui-container">

    <div class="layui-row layui-col-space15">
        <!--左侧帖子内容区域-->
        <div class="layui-col-md8">
            <!--帖子详情区域-->
            <div class="fly-panel detail-box">
                <!--标题-->
                <h1>@Model.data.Title</h1>

                <!--帖子信息-->
                <div class="fly-detail-info">

                    <!--帖子类型-->
                    <span class="layui-badge layui-bg-green">
                        @Model.data.PostTypeStr
                    </span>

                    <!--帖子状态-->
                    @if (Model.data.IsEnd)
                    {
                        <span class="layui-badge" style="background-color:#5FB878;">已结</span>
                    }
                    else
                    {
                        <span class="layui-badge" style="background-color:#999;">未结</span>
                    }

                    @if (Model.data.IsTop)
                    {
                        <span class="layui-badge layui-bg-black">置顶</span> 
                    }
                    @if (Model.data.IsCream)
                    {
                        <span class="layui-badge layui-bg-red">精帖</span>
                    }

                    <!--判断管理员身份，展示操作按钮-->
                    @if (Model.data.IsManageUser)
                    {
                        <div class="fly-admin-box" id="post_Operate" data-id="@Model.data.PostId">
                            <span class="layui-btn layui-btn-xs" operate-type="10">删除</span>

                            @if (Model.data.IsTop)
	                        {
                                <span class="layui-btn layui-btn-xs" style="background-color:#ccc;" operate-type="20">取消置顶</span>
                            }
                            else
                            {
                                <span class="layui-btn layui-btn-xs" operate-type="20">置顶</span>
                            }
                            @if (Model.data.IsCream)
	                        {
		                         <span class="layui-btn layui-btn-xs" style="background-color:#ccc;" operate-type="30">取消加精</span>
                            }
                            else
                            {
                                <span class="layui-btn layui-btn-xs" operate-type="30">加精</span>
                            }
                            @if (!Model.data.IsEnd)
                            {
                                <span class="layui-btn layui-btn-xs" operate-type="40">结帖</span>
                            }
                        </div>
                    }

                    <!--帖子阅读次数及回复次数-->
                        <span class="fly-list-nums">
                            <span href="#comment">
                                <i class="iconfont" title="回答">&#xe60c;</i>@Model.data.ReplyCount
                            </span>
                            <i class="iconfont" title="人气">&#xe60b;</i>@Model.data.ViewCount
                        </span>
                </div>

                <!--帖子发布者信息-->
                <div class="detail-about">
                    <a href="@Url.Action("UserCenter","User",new {userId=Model.data.UserId })" class="fly-avatar">
                        <img src="@Model.data.HeadImgUrl" />
                    </a>
                    <div class="fly-detail-user">
                        <a href="@Url.Action("UserCenter","User",new {userId=Model.data.UserId })" class="fly-link">
                            @Model.data.NickName
                            @if (Model.data.IsApprove)
	                        {
                                  <i class="iconfont icon-renzheng" title="认证信息：@Model.data.ApproveMsg" ></i>
	                        }
                            <i class="layui-badge fly-badge-vip">@Model.data.UserIdentityStr</i>
                        </a>
                        <span>@Model.data.PublishTimeSpan</span>
                    </div>

                    <!--发帖用户操作-->
                    <div class="detail-hits" id="postCollection">
                        @if (Model.data.IsPublishUser)
                        {
                            <span class="layui-btn layui-btn-xs">
                                <a href="@Url.Action("Update",new { postId=Model.data.PostId})" style="color:#fff">编辑此贴</a>
                            </span>
                        }
                        @if (Model.data.IsCollection)
                        {
                            <span class="layui-btn layui-btn-xs" post-collection="cancel">
                                <span href="">取消收藏</span>
                            </span>
                        }
                        else
                        {
                            <span class="layui-btn layui-btn-xs layui-btn-danger" post-collection="collection">
                                <span href="">收藏</span>
                            </span>
                        }
                    </div>
                </div>

                <!--帖子内容区域-->
                <div class="detail-body">
                    @Html.Raw(Model.data.HtmlContent)
                </div>
            </div> 

            <!--帖子回复区域-->
            <div class="fly-panel detail-box">
                <fieldset class="layui-elem-field layui-field-title" style="text-align:center;">
                    <legend>回帖</legend>
                </fieldset>

                <ul class="jieda">
                    @if (Model.data.ReplyCount==0)
                    {
                        <li class="fly-none">消灭零回复</li>
                    }
                    else
                    {
                        foreach(var reply in Model.data.ReplyList)
                        {
                            <li>
                                <div class="detail-about detail-about-reply">
                                    <a href="@Url.Action("UserCenter","User",new {userId=Model.data.UserId })" class="fly-avatar">
                                        <img src="@reply.HeadImgUrl"/>
                                    </a>
                                    <div class="fly-detail-user">
                                        <a href="@Url.Action("UserCenter","User",new {userId=Model.data.UserId })" class="fly-link">
                                            <cite>@reply.NickName</cite>
                                            @if (reply.IsApprove)
                                            {
                                                <i class="iconfont icon-renzheng" title="认证信息：@reply.ApproveMsg"></i>
                                            }
                                                <i class="layui-badge fly-badge-vip">@reply.UserIdentityStr</i>
                                        </a>
                                        @if (reply.UserId==Model.data.UserId)
                                        {
                                            <span>(楼主)</span>
                                        }
                                    </div>

                                    <div class="detail-hits">
                                        <span>@reply.ReplyTimeTimeSpan</span>
                                    </div>
                                    @if (reply.IsAccept)
                                    {
                                        <i class="iconfont icon-caina" title="最佳答案"></i>
                                    }
                                </div>

                                <div class="detail-body jieda-body">
                                    @Html.Raw(reply.HtmlContent)
                                </div>
                                <div class="jieda-reply">
                                    <span class="jieda-zan">

                                    </span>
                                    <div class="jieda-admin">
                                        @if (!reply.IsAccept)
                                        {
                                            if (reply.IsReplyUser||Model.data.IsManageUser)
                                            {
                                                <span id="replyDelete" replyId="@reply.ReplyId" click-event="delete">删除</span>
                                            }
                                        }
                                        @if (Model.data.IsPublishUser && !Model.data.IsAccept)
                                        {
                                            <span id="replyAccept" replyId="@reply.ReplyId" click-event="accept">采纳</span>
                                        }
                                    </div>
                                </div>
                            </li>
                        }
                    }
                </ul>

                <!--回复分页区域-->
                <div style="text-align:center">
                    <div id="replyPage"></div>
                </div>

                <!--帖子回复区域-->
                <div class="layui-form layui-form-pane">
                    <div class="layui-row">
                        <div class="layui-col-xs12">
                            <div class="layui-form-item layui-form-text">

                                <!--用于回复跳转定位-->
                                <span name="comment"></span>
                                <textarea lay-verify="required" class="layui-textarea fly-editor" id="ReplyContent" name="ReplyContent" flie-tag="PostReply" style="height:150px"></textarea>
                            </div>
                        </div>
                        <div class="layui-col-xs12">
                            <div class="layui-form-item">
                                <button class="layui-btn" lay-submit lay-filter="postReply">提交回复</button>
                            </div>
                        </div>

                        <input type="hidden" name="RelationGuid" id="relationGuid" value="@Guid.NewGuid().ToString()" />
                        <input type="hidden" name="PostId" value="@Model.data.PostId" />
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md4">
            <div class="fly-panel">
                <div class="fly-panel-title">
                    学习C#.NET
                </div>
                <div class="fly-panel-main">
                    <a href="https://xiketang.ke.qq.com" target="_blank" class="fly-zanzhu" time-limit="2019.07.09-2099.01.01" style="background-color:#5FB878;">.NET高级进阶VIP</a>
                </div>
            </div>

            <div class="fly-panel" style="padding:20px 0; text-align:center;">
                <img src="~/Content/image/weixin.jpg" alt="layui" style="max-width:100%;" />
                <p style="position:relative;color:#666;">微信扫码关注 喜科堂互联教育 公众号</p>
            </div>
        </div>

    </div>
</div>
<script type="text/javascript">
    layui.cache.module={
        moduleName:'post',
        pageName: 'detailPage',
        postId:@Model.data.PostId,
        pageIndex:@Model.page,
        totalCount:'@Model.data.ReplyCount'
    }
</script>
